/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yonsei.iwb.sdt.ontology;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.NodeIterator;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author JDK
 */
public class ClassModel extends Hashtable<Resource, UnitClassModel> {
        
    public void classModelMaker(Model model) {

//        StmtIterator iter1 = model.listStatements(null, RDF.type, OWL.Class);
//
//        while (iter1.hasNext()) {
//            
//            Statement stmt = iter1.nextStatement();
//            Resource centerclass = stmt.getSubject();
//            UnitClassModel ucm = new UnitClassModel(centerclass);
////            ucm.centerclass = stmt.getSubject();
////            System.out.println("class : " + ucm.centerclass.getLocalName());
//            findConnectedProperty(centerclass, model, ucm);
//            
//            NodeIterator resit = model.listObjectsOfProperty(centerclass, RDFS.subClassOf);
//            while (resit.hasNext()) {
//                Resource superclass = resit.nextNode().asResource();
//                findConnectedProperty(superclass, model, ucm);
//            }
//
//            this.put(centerclass, ucm);
//
//        }
    }

    public void classModelMaker(Model ontmodel, Property tp) {
//
//        StmtIterator iter1 = ontmodel.listStatements(null, RDF.type, OWL.Class);
//
//        while (iter1.hasNext()) {
//            
//            Statement stmt = iter1.nextStatement();
//            Resource centerclass = stmt.getSubject();
//            UnitClassModel ucm = new UnitClassModel(centerclass);
//
//            StmtIterator iter2 = ontmodel.listStatements(null, RDFS.domain, stmt.getSubject());
//            while (iter2.hasNext()) {
//                Statement stmt2 = iter2.nextStatement();
//
//                Resource p = stmt2.getSubject();
//                StmtIterator iter3 = ontmodel.listStatements(p, RDF.type, OWL.DatatypeProperty);
//                StmtIterator iter4 = ontmodel.listStatements(p, RDF.type, OWL.ObjectProperty);
//
//                if (iter3.hasNext()) {
////                    System.out.println("this is datatype");
//                    if (!tp.asResource().equals(p)) {
//                        ucm.dataTypeProperty.add(p.asResource());
//                    }
//
//                } else if (iter4.hasNext()) {
//                    ucm.objectProperty.add(p.asResource());
////                    System.out.println("this is object");
//                }
//
//            }
//
//            this.put(centerclass, ucm);
//
//        }
    }

    public void printClassModel() {
        for (int i = 0; i < this.size(); i++) {
//            System.out.println("======================================");
            UnitClassModel ucm = this.get(i);
            ucm.printUnitClassModel();
//            System.out.println("======================================");
        }
    }
}
